package org.example.petsystem.controller;

import org.example.petsystem.entity.ResultBody;
import org.example.petsystem.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/Notice")
@CrossOrigin(origins="*")
public class NoticeController {
    @Autowired
    private NoticeService noticeService;
    @RequestMapping("/sendNotice")
    public ResultBody sendNotice(@RequestBody Map<String,Object> map)
    {
       if(map.get("topic")==null||map.get("content")==null)
       {
           return new ResultBody(404,"缺少参数",false);
       }
       return noticeService.sendNotice(map);
    }
    @RequestMapping("/displayNotice")
    public ResultBody displayNotice()
    {
        return noticeService.displayNotice();
    }
    @RequestMapping("/DelNotice")
    public ResultBody DelNotice(@RequestBody Map<String,Object> map)
    {
        if(map.get("id")==null)
        {
            return new ResultBody(404,"缺少参数",false);
        }
        return noticeService.DelNotice(map);
    }
}
